<template>
  <div class="card-list" ref="content">
    <a-list rowKey="id" :grid="{gutter: 10, lg: 3, md: 2, sm: 1, xs: 1}" :dataSource="dataSource">
      <a-list-item slot="renderItem" slot-scope="item">
        <template v-if="!item || item.id === undefined">
          <a-button class="new-btn" type="dashed">
            <a-icon type="plus" />新增项目
          </a-button>
        </template>
        <template v-else>
          <a-card :hoverable="true" :key="item.id">
            <a-card-meta  @click="tabChange(item)">
              <a slot="title">{{ item.title }}</a>
              <a-avatar class="card-avatar" slot="avatar" :src="item.avatar" size="large" />
              <div class="meta-content" slot="description">{{ item.content }}</div>
            </a-card-meta>
            <template class="ant-card-actions" slot="actions">
              <a>配置管理员</a>
              <a>删除</a>
            </template>
          </a-card>
        </template>
      </a-list-item>
    </a-list>
  </div>
</template>

<script>
const dataSource = [];
dataSource.push({});
for (let i = 0; i < 4; i++) {
  dataSource.push({
    id: i,
    title: "01-举重",
    avatar: "../../assets/logo.png",
    content: "13124321513515"
  });
}

export default {
  mounted() {
  },
  name: "CardList",
  data() {
    return {
      dataSource: [{
    id:1,
    title: "01-举重",
    avatar: "../../assets/logo.png",
    content: "13124321513515"
  },{
    id: 2,
    title: "02-三级跳",
    avatar: "../../assets/logo.png",
    content: "13124321513515"
  }]
    };
  },
  methods: {
    tabChange(item) {
      console.log(item)
      this.$router.push({
        name:'team'
      })
    }
  }
};
</script>

<style lang="scss" scoped>
.card-list {
  /deep/ .ant-card-body:hover {
    .ant-card-meta-title > a {
      color: #aaabac;
    }
  }

  /deep/ .ant-card-meta-title {
    margin-bottom: 12px;

    & > a {
      display: inline-block;
      max-width: 100%;
      color: rgba(0, 0, 0, 0.85);
    }
  }

  /deep/ .meta-content {
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    height: 64px;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    margin-bottom: 1em;
  }
}

.card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 48px;
}

.ant-card-actions {
  background: #f7f9fa;

  li {
    float: left;
    text-align: center;
    margin: 12px 0;
    color: rgba(0, 0, 0, 0.45);
    width: 50%;

    &:not(:last-child) {
      border-right: 1px solid #e8e8e8;
    }

    a {
      color: rgba(0, 0, 0, 0.45);
      line-height: 22px;
      display: inline-block;
      width: 100%;
      &:hover {
        color: #aaabac;
      }
    }
  }
}

.new-btn {
  background-color: #fff;
  border-radius: 2px;
  width: 100%;
  height: 188px;
}
</style>
